/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fjtu.se1603.lh;

import edu.fjtu.se1603.lh.dao.Impl.PetImpl;
import edu.fjtu.se1603.lh.dao.Impl.PetODaoImpl;
import edu.fjtu.se1603.lh.dao.Impl.PetstoreImpl;
import edu.fjtu.se1603.lh.entity.Petstore;
import edu.fjtu.se1603.lh.util.DBUtil;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class loin {
       
    
   
         public static void main(String[] args) throws SQLException {
         System.out.println("宠物商店启动");
         System.out.println("Wonderland醒来，所有宠物从oracle中醒来");
         System.out.println("***********************************************************************");
         
         PetImpl a;
         a=new PetImpl();
         
         a.getById1(1);  a.getById1(2); a.getById1(3);  a.getById1(4);a.getById1(5);a.getById1(6);
         System.out.println("***********************************************************************");
         System.out.println("所有宠物主人从oracle中醒来");
         System.out.println("***********************************************************************");
         
          PetODaoImpl b;
          b=new PetODaoImpl();  
          b.getById(1); b.getById(2); b.getById(3);
          
         System.out.println("***********************************************************************");
         System.out.println("所有宠物商店从oracle中醒来");
         System.out.println("***********************************************************************");
         
             PetstoreImpl c;
             c=new PetstoreImpl();
             
             c.getById2(1);c.getById2(2);
         System.out.println("***********************************************************************");
             Scanner input=new Scanner(System.in);
            System.out.println("请选择登录方式，输入1为宠物主人登录，输入2为宠物商店登录"); 
            int  choice = input.nextInt();
             if (choice==1) {
                   Scanner input1=new Scanner(System.in);
                 System.out.println("请先登录，输入主人的名字：");
                 String ownername=input1.nextLine();
            
                 System.out.println("请您输入主人的密码：");
                 String ownerpwd=input1.nextLine();
             
      
            Connection con=DBUtil.getConnection();
            ResultSet rs = con.createStatement().executeQuery("select*from petowner where NAME='"+ownername+"'and PASSWORD='"+ownerpwd+"'");
     
            if(rs.next()){
              System.out.println("---------恭喜您成功登录----------");
              System.out.println("---------您的基本信息：----------");
                b=new PetODaoImpl();
                b.getByname(ownername);
                
                
                 Scanner input2=new Scanner(System.in);
                System.out.println("登录成功，您可以购买和卖出宠物，购买宠物请输入1 ，卖出宠物请输入2");
                System.out.println("1.购买宠物");
                System.out.println("2.卖出宠物");
                 int  choice2 = input2.nextInt();
                   if (choice2==1) {
                   System.out.println("---------请输入要购买的范围：只输入选择项的序号----------");
                    System.out.println("1.购买库存宠物");
                    System.out.println("2.购买新培育宠物");
                     int  choice3 = input.nextInt();
                      if (choice3==1) {
                      System.out.println("---------以下是库存宠物----------");
                       a=new PetImpl();
                       a.getById11(1); a.getById11(2); a.getById11(3); a.getById11(4);
                       
                 Scanner input3=new Scanner(System.in);   
                 System.out.println("---------请选择要购买哪一个宠物，并输入选择项的序号----------");
                  int  choice4 = input3.nextInt();
                   a.getById11(choice4);
                   b.getid(ownername);
                          System.out.println("台账正确插入一条信息");
                          
                      }
                      else if (choice2==2) {
                           System.out.println("---------我的宠物列表----------");
                           System.out.println("1.购买宠物");
                           System.out.println("2.卖出宠物");
                            a.getById11(1); a.getById11(2); a.getById11(3); a.getById11(4);
                             System.out.println("---------请选择要出售的宠物序号----------");
                       }
                   }
                       
            }else{
                System.out.println("登录失败");
            }
            
                 
             }
         
           
   
}
}
